﻿using System.Windows.Input;

namespace CourseManagerment.Common;

public class CommandBase : ICommand
{
    public event EventHandler CanExecuteChanged;
    /// <summary>
    /// 是否可执行，通用方法，传入委托
    /// </summary>
    /// <param name="parameter"></param>
    /// <returns></returns>
    public bool CanExecute(object parameter)
    {
        return DoCanExecute?.Invoke(parameter) == true;
    }
    /// <summary>
    /// 执行
    /// </summary>
    /// <param name="parameter"></param>
    public void Execute(object parameter)
    {
        DoExecute?.Invoke(parameter);
    }

    public Action<object> DoExecute { get; set; }
    public Func<object, bool> DoCanExecute { get; set; }
}
